<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        // 利用函数翻转任意数组
        function reverse(arr) {
            let newArr = [];
            for (let i = arr.length - 1; i >= 0; i--) {
                newArr[newArr.length] = arr[i];
            }
            return newArr;
        }
        let arr1 = reverse([1, 2, 3, 4, 5, 6]);
        console.log(arr1);



        // 利用函数封装 数组排序（冒泡排序） 5
        function maopao(arr) {
            for (let i = 0; i < arr.length - 1; i++) {
                for (let j = 0; j < arr.length - i - 1; j++) {
                    // let temp;
                    // temp = i;
                    // i = j;
                    // j = temp;
                    if (arr[j] > arr[j + 1]) {
                        //变量的交换
                        let temp = arr[j];
                        arr[j] = arr[j + 1];
                        arr[j + 1] = temp;
                    }


                }
            }
            return arr;
        }
        let m = maopao([4, 2, 3, 1, 5])
        console.log(m);




        // 函数封装判读闰年
        function ifRunyear(year) {
            if (year % 4 == 0 && year % 100 != 0 || year % 400 == 0) {
                return true;
            } else
                return false;
        }

        let years = ifRunyear(2000);
        console.log(years);

        console.log(ifRunyear(1999));
    </script>
</body>

</html>